#!/bin/bash
function killproject()
{
  project_pid=$(netstat -lnp | grep 8090|awk '{print $7}'|cut -d/ -f1)
  if [  $project_pid > 0 ];then
        echo "项目已经启动了，开始关闭项目，项目pid为: $project_pid "
        kill -9 $(netstat -lnp | grep 8090|awk '{print $7}'|cut -d/ -f1)
        echo '项目关闭成功，开始重启项目。。。'
  else
        echo "项目未启动，直接启动"
  fi
}
function start_project()
{
        source /etc/profile
        echo '正在启动项目。。。'
        cd target
        nohup java -jar spring-boot-practice-1.0.jar >publish.log &2>1 &

}
function check_project()
{
  check_pid=$(netstat -lnp | grep 8090|awk '{print $7}'|cut -d/ -f1)
  if [ $check_pid  > 0 ];then
        echo "project is start and  pid = : $check_pid  "
  else
        echo "project are not start"
  fi

}
killproject
start_project
sleep 15
check_project
